package com.hcss.common.util;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * @Author: 可乐
 * @Description: 用来裁剪图片大小的工具包
 * @CreateTime: 2023-02-28  09:09
 */
public class PictureUtill {

	/**
	 * 改变图片尺寸
	 * @param srcFileName 源图片路径
	 * @param path        图片修改后路径
	 * @param width       修改后的宽度
	 * @param height      修改后的高度
	 */
	public static void zoomImage(String srcFileName,String path,int width,int height){
		try {
			BufferedImage bi = ImageIO.read(new File(srcFileName));
			BufferedImage tag=new BufferedImage(width,height, BufferedImage.TYPE_INT_RGB);
			tag.getGraphics().drawImage(bi, 0, 0, width, height, null);
			ImageIO.write(tag, "jpg", new File(path));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
